<!DOCTYPE HTML>
<html>
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@page import="com.beidouapp.security.model.SessionUser"%>
<%@page import="com.beidouapp.security.utils.DscpCommUtils" %>    
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="<%=request.getContextPath()%>/css/common/H-ui.min.css" rel="stylesheet" type="text/css"/>
<link href="<%=request.getContextPath()%>/css/common/H-ui.admin.css" rel="stylesheet" type="text/css"/>
<link href="<%=request.getContextPath()%>/css/iconfont/iconfont.css" rel="stylesheet" type="text/css"/>
<link href="<%=request.getContextPath()%>/css/font-awesome/font-awesome.min.css" rel="stylesheet" type="text/css"/>
<link href="<%=request.getContextPath()%>/css/common/styleWeb.css?1.4" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=oD3q5GGL8naqx03pfIBmFjhj951q6IXg"></script>
<title>工程师位置分布</title>
</head>
<body>
<div class="engineer_L f-l">
<div class="engineer_L_logo text-c f-l"><a href="<%=request.getContextPath()%>/api/index/showEngineerPos"><img src="<%=request.getContextPath()%>/images/engineer/engineer_logo.png" /></a></div>
<ul class="list-unstyled engineer_L_item f-l">
<li class="text-c f-l" data-num="1">
<div><img src="<%=request.getContextPath()%>/images/engineer/engineer_eng.png" /></div>
<div class="engineer_L_item_h f-l"><h2>${engineerTotal}<small>位</small></h2><span>活跃工程师</span></div>
</li>
<li class="text-c f-l" data-num="2">
<img src="<%=request.getContextPath()%>/images/engineer/engineer_persent.png" />
<div class="engineer_L_item_h f-l"><h2>${projectTotal}<small>个</small></h2><span>项目</span></div>
</li>
</ul>
</div>	
<div class="engineer_R f-l">
<div class="engineer_R_title f-l"><h1 class="f-l">天衣物联全景BOSS系统</h1><div class="f-r"><img alt="" src="<%=request.getContextPath()%>/images/engineer/engineer_admin.png" />
<span onclick="showLogin()" style="cursor:pointer" id="loginName">
 <%=DscpCommUtils.getSessionUser(request.getSession())==null?"管理员登录":DscpCommUtils.getSessionUser(request.getSession()).getUserName()%>
		<!--  <a target=\"_self\" href=\""+request.getContextPath()+"/api/main\">"+DscpCommUtils.getSessionUser(request.getSession()).getUserName()+"</a>"%> -->
</span>
</div></div>
<div class="engineer_R_info f-l">
<div class="engineer_R_info_map f-l" id="allmap"></div>
<div class="engineer_R_info_search f-l">
<div class="f-l engineer_R_info_search_b mb-10"><button type="button" class="btn btn-success"><i class="iconfont iconfont-zhexiantu"></i>&nbsp;&nbsp;查看工程师增长趋势图</button></div>
<div class="engineer_R_info_search_s f-l"><select class="f-l" id="engineerSelect"><option value="全国" selected>全国</option></select><span class="text-c f-l" onclick="doSearch()"><img src="<%=request.getContextPath()%>/images/engineer/engineer_search.png" /></span></div>
<table class="table table-hover table-bordered table-striped engineerTable f-l">
<thead class="text-c"><tr><th id="provinceWord">省份</th><th>工程师数/位</th><th>项目数/个</th></tr></thead>
<tbody class="text-c"></tbody>
</table>
</div>
</div>
</div>	
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/common/jquery.min.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/layer1.8/layer.min.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/common/H-ui.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/common/H-ui.admin.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/common/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/engineer/engineerPosition.js?1.8"></script>
<script type="text/javascript">
if(window.top!=window){
	window.top.location="<%=request.getContextPath()%>/api/tologin";
}
var baseURL="<%=request.getContextPath()%>";
var map = new BMap.Map("allmap");
var point = new BMap.Point(103.359, 53.795);
var isPrivinceFlag=false;
var isCityFlag=false;
map.centerAndZoom(point, 5);
map.enableScrollWheelZoom(true);
//百度地图API功能
var numProvince = 0;
var numCity = 0;
var myGeo = new BMap.Geocoder();
var addsProvince = [];
var addscity = [];
var realCity=[];
function bdGEO(){
	var name = addsProvince[numProvince][0];
	var engineerTotal = addsProvince[numProvince][1];
	var projectTotal = addsProvince[numProvince][2];
	geocodeSearch(name,engineerTotal,projectTotal);
}
function geocodeSearch(add,engineerTotal,projectTotal){
	if(numProvince<addsProvince.length-1){
		numProvince++;
		setTimeout(bdGEO,100);
	}
	if(numProvince==addsProvince.length-1){
		isPrivinceFlag=true;
		isCityFlag=true;
	}else{
		isPrivinceFlag=false;
		isCityFlag=false;
	}
	myGeo.getPoint(add, function(point){
		if (point) {
			var address = new BMap.Point(point.lng, point.lat);
			//addMarker(address,new BMap.Label(render(),{offset:new BMap.Size(15,-40)}));
			addMarker(address,new BMap.Label("<div onclick=getBoundary('"+add+"')><span style='color:#BA5007;fontSize:14px;font-weight:800'>"+add+"</span><br />工程师："+engineerTotal+"<br />项&nbsp;&nbsp;&nbsp;&nbsp;目："+projectTotal+"</div>",{offset:new BMap.Size(15,-60)}));
		}
	});
}

/* function render(){
	var header = "<div style='float:left;width:80px;list-style:none outside;border-bottom:#999999 1px solid;border-right:#999999 1px solid'>湖南省</div>";
	
	var content = "<div><li><div style='float:left;width:80px;list-style:none outside;border-bottom:#999999 1px solid;border-right:#999999 1px solid'>123</div><div class='right'>223</div></li><li>223</li><li>224</li></div";
	return content;
} */
//点击到市区
function bdGEO1(){
	if(realCity==""||realCity.length==0) return;
	var add = realCity[numCity][0];
	var provice = realCity[numCity][3];
	var engineerTotal = realCity[numCity][1];
	var projectTotal = realCity[numCity][2];	
	geocodeSearch1(add,engineerTotal,projectTotal,provice);
}
function geocodeSearch1(add,engineerTotal,projectTotal,province){
	if(numCity<realCity.length-1){
		numCity++;
		setTimeout(bdGEO1,200);
	} 
	if(numCity==realCity.length-1){
		isCityFlag=true;
	}else isCityFlag=false;
	myGeo.getPoint(add,function(point){
		if (point) {
			var address = new BMap.Point(point.lng, point.lat);
			addMarker(address,new BMap.Label("<span style='color:#BA5007;fontSize:14px;font-weight:800'>"+province+add+
					"</span><br />工程师："+engineerTotal+"<br />项&nbsp;&nbsp;&nbsp;&nbsp;目："+projectTotal,{offset:new BMap.Size(15,-60)}));
		}
	});
}
// 编写自定义函数,创建标注
function addMarker(point,label){
	var marker = new BMap.Marker(point);
	map.addOverlay(marker);
	label.setStyle({
		 color : "#fff",
		 fontSize : "12px",
		 height : "60px",
		 lineHeight : "20px",
		 border:"1px solid #e65c00",
		 background:"#ff9900"
    });
	marker.setLabel(label);
}
//行政区域
function getBoundary(obj){
	if(!isPrivinceFlag){
		layer.msg("数据正在加载中,请稍后操作");
		return;
	}
	map.clearOverlays(); 
	numCity=0;
	realCity=[];
	$.each(addscity,function(i,n){
		if(obj==n[3]){
			realCity.push(n);
		}
	})
	var bdary = new BMap.Boundary();
	bdary.get(obj, function(rs){       //获取行政区域
		map.clearOverlays();        //清除地图覆盖物       
		var count = rs.boundaries.length; //行政区域的点有多少个
		if (count === 0) {
			layer.msg('未能获取当前输入行政区域');
			return ;
		}
      	var pointArray = [];
		for (var i = 0; i < count; i++) {
			var ply = new BMap.Polygon(rs.boundaries[i], {strokeWeight: 2, strokeColor: "#ff0000"}); //建立多边形覆盖物
			map.addOverlay(ply);  //添加覆盖物
			pointArray = pointArray.concat(ply.getPath());
		}    
		map.setViewport(pointArray);    //调整视野  
		bdGEO1();
	}); 
}

function showLogin(){
	var loginName = "";
	$.ajax({
		url:baseURL+'/api/isLogin?t='+new Date().getTime(),
		type:'GET',
		dataType:'json',
		timeout : 30000,
		contentType : "application/json; charset=utf-8",
		success : function(result) {
			 if(result.statusCode==200){
				loginName =  result.result.userName;
			 }
			 if(loginName==""){
				  $("#loginName").text("管理员登录");
				  layer_show(650,'500','登录',baseURL+'/api/login?t='+new Date().getTime());	
			  }else{
				  $("#loginName").text(loginName);
				  window.location = baseURL+"/api/main?t="+new Date().getTime();
			  }
		  }    
     });
}

</script>
</body>
</html>